<%@page import="com.bci.pwtz.common.util.SpringUtil"%>
<%@page import="com.bci.pwtz.service.CompanyRoleService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.bci.pwtz.mysql.model.CompanyMenu"%>
<%@ page import="com.bci.pwtz.common.PwtzConstants"%>
<%	
	List<CompanyMenu> list = (List<CompanyMenu>) PwtzConstants.COMPANY_MENU;
	String currentUrl = request.getRequestURI();
	CompanyRoleService leftCompanyRoleService = (CompanyRoleService)SpringUtil.getBean("companyRoleService");
%>
<%!
public String getCurrentCssClass(String currentUrl,String className,String url)
{
    if(url!=null && url.contains("?")){
        url= url.substring(0,url.lastIndexOf("?"));
    }
    if(currentUrl.equals(url))
        return className+"_cur";
    else if(currentUrl.contains("/z/") && url.contains("/z/"))
        className = "left_tree_zygl_cur";
    else if(currentUrl.contains("/d/") && url.contains("/d/"))
        className = "left_tree_dygl_cur";
    else if(url.equals("/pwtz/user/m/rolelist.jsp") && currentUrl.contains("/membermanagement.jsp"))
        className = "left_tree_qxgl_cur";
    else if(url.equals("/pwtz/user/m/vdystatlist.jsp") && currentUrl.contains("/vzystatlist.jsp"))
        className = "left_tree_pdsjtj_cur";
    return className;
}
%>
<!-- 左侧内容_begin -->
<div class="pwsj_cont_left_box">
   <%if(list.size()>0){ 
   	for(int i=0;i<list.size();i++){
   		CompanyMenu companyMenu = list.get(i);
   		//out.print(companyMenu.getCompanyMenus().size());
   		boolean flag = false;
   		for(int j=0;j<companyMenu.getCompanyMenus().size();j++)
   		{
   		 	 CompanyMenu menu = companyMenu.getCompanyMenus().get(j); 	
	   		 String actionCodes = menu.getActionCode();
	   		 if(leftCompanyRoleService.checkHasAction(request, actionCodes))
	   		 {
	   		  	 flag = true;
	   		     break;
	   		 }   		     
   		}
   		
   		if(flag){
   		%>
   		<div class="left_tree_box">
   		<h2 class="left_tree_title"><%=companyMenu.getMenuText()%></h2>
   		<div class="left_tree_cont" style="display: none;">
   		 <%
   			for(int j=0;j<companyMenu.getCompanyMenus().size();j++){
   				CompanyMenu menu = companyMenu.getCompanyMenus().get(j);
   				String[] menuUrlAndClass = menu.getMenuUrl().split(",");
   				String actionCodes = menu.getActionCode();
   				if(leftCompanyRoleService.checkHasAction(request, actionCodes))
   				{
   				%>
   				<a href="<%=menuUrlAndClass[0]%>" class="<%=getCurrentCssClass(currentUrl,menuUrlAndClass[1],menuUrlAndClass[0])%>"><%=menu.getMenuText() %></a>
   				<%
   				}
   			}
   			%>
   			</div>
   			</div>
   			<%
   		}
   	} 
   }%>
   
</div>
<!-- 左侧内容_end -->
<script type="text/javascript">
$(function(){
	$("a[class $= '_cur']").parent().show();
});
</script>
